﻿<?php
  
  
  require("abifunktsioonid.php");
   $otsisona="";
  session_start();
 if($_SESSION["group_type"]!="0"){
 header("Location: login.php");
 exit();
 }
 
 if(isSet($_REQUEST["lahku"])){
 unset($_SESSION["username"]);
  header("Location: login.php");
 exit();
 }
  
  
  if(isSet($_REQUEST["lepingulisamine"])){
    lisaLeping($_REQUEST["customer_id"], $_REQUEST["assignment"], $_REQUEST["location"]);
    header("location: customer_add.php");
    exit();
  }
  if(isSet($_REQUEST["kustutusid"])){
     kustutaLeping($_REQUEST["kustutusid"]);
  }
  if(isSet($_REQUEST["muutmine"])){
     muudaLeping($_REQUEST["muudetudid"], $_REQUEST["assignment"], $_REQUEST["location"], $_REQUEST["complete"]);
  }
  
 

  if(isSet($_REQUEST["otsisona"])){
     $otsisona=$_REQUEST["otsisona"];
  }
  $tootajad=kysiKliendiAndmed($otsisona);
 
 $dis=$_SESSION["customer_id"];
 echo "$dis";
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
 <meta charset="UTF-8"/>
<link rel="stylesheet" type="text/css" href="kujundus.css">
 <title>Bon Services OY</title>

 </head>
 <body>
<div id="main">
 <img id="header" src="bso.png" alt="logo" href="login.php"/>
 </div>
 <div id="main2">

 <div id="main3">
 
 
 
  <form id="located" action="customer_add.php">
     <dl>
	 <dt>Kliendi number:</dt>
       <dd><input id="otsing" type="text" name="customer_id" /></dd>
       <dt>Lepingu nimi:</dt>
       <dd><input id="otsing" type="text" name="assignment" /></dd>
       <dt>Asukoht:</dt>
       <dd><input id="otsing" type="text" name="location" />
       </dd>
     </dl>
     <input type="submit" name="lepingulisamine" value="Lisa leping" />
     
   </form>
   <div id="kliendinimekiri">
   <p>Meie püsiklientide numbrid</p>
   <table>
   <tr>
   <th>Klient</th>
   <th>Kliendinumber</th>
   </tr>
   <tr>
   <td id="rida">KaPo</td>
   <td id="rida">1</td>
   </tr>
   <tr>
   <td id="rida">NSA</td>
   <td id="rida">2</td>
   </tr>
   <tr>
   <td id="rida">FSB</td>
   <td id="rida">3</td>
   </tr>
   <tr>
   <td id="rida">CIA</td>
   <td id="rida">4</td>
   </tr>
   <tr>
   <td id="rida">FBI</td>
   <td id="rida">5</td>
   </tr>
   <tr>
   <td id="rida">GESTAPO</td>
   <td id="rida">6</td>
   </tr>
   </table>
   
   </div>
	 
	 <form style="margin-top:90px;" action="?">
     Otsitav väärtus: <input id="otsing" type="text" name="otsisona" />
	 <br/>
	<br/>
     <table id="workers" >
	 
		<tr>
			<th>Klient</th>
			<th>Leping</th>
			<th>Asukoht</th>
			<th>Valmidus</th>			
		</tr>
  
       <?php foreach($tootajad as $tooline): ?>
         <tr>
		   <td id="rida"><?php echo $tooline->customer?></td>
		   <td id="rida"><?php echo $tooline->assignment?></td>
		   <td id="rida"><?php echo $tooline->location?></td>
		   <td id="rida"><?php if($tooline->complete=="0"){echo "Ei ole täidetud";} elseif($tooline->complete=="1"){echo "Täidetud";}?></td>
           
         </tr>
       <?php endforeach; ?>
     </table>
	 
	 
	 <div id="kasutaja">
	 <a href="login.php" id="tagasi">Tagasi</a>
	  <p id="kasutajad"><?php echo $_SESSION["realname"]; ?>
 <a href="?lahku" id="lahku">lahku</a></p>
 </div>
	 </div>
	 
	 </div>
  </body>
</html>